home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-25 | 4.2 KB | 130 lines | [TEXT/CWIE] |
- //========================================================================================
- //
- // Additive Dissolve.c - Additive crossfade transition.
- //
- // Part of the Adobe Premiere¬ 4.2 Plug-In Developer's Toolkit.
- //
- // Written by Randy Ubillos and Bryan K. "Beaker" Ressler.
- //
- // Copyright ⌐ 1993-96, Adobe Systems Incorporated, all rights reserved worldwide.
- //
- // Version 1.00 10/20/93 Original version.
- // Version 1.01 9/12/94 Updated for 4.0.
- // Version 1.02 10/6/95 Updated for 4.2 and CW7.
- //
- //========================================================================================
-
- //========================================================================================
- // Includes - use precompiled headers if compiling with CodeWarrior.
- //========================================================================================
- #ifdef __MWERKS__
- #ifdef powerc
- #include "PremierePPC"
- #else
- #include "Premiere68k"
- #endif
- #else
- #include "Premiere.h"
- #endif
-
- //========================================================================================
- // Perform the transition
- //========================================================================================
- pascal short main (short selector, EffectHandle theData)
- {
- short result = 0;
- long spot;
- Rect box;
- RGBColor theColor, pin;
- GWorldPtr oldWorld;
- GDHandle oldDev;
-
- // Save the current GWorld/GDevice
- GetGWorld(&oldWorld, &oldDev);
-
- // Act according to the selector
- switch (selector) {
- case esExecute:
- // Preset pin color to pure white. Retrieve box for use in the CopyBits calls.
- pin.red = pin.green = pin.blue = 0xFFFF;
- box = ((GrafPtr)(*theData)->destination)->portRect;
-
- // calculate percentage of 131071
- spot = (*theData)->part * (long)131071 / (*theData)->total;
-
- if (spot < 65536) {
- // We're in the first half of the transition (0% - 50%)
-
- // Calculate the mixing value and set OpColor accordingly
- theColor.red = theColor.green = theColor.blue = spot;
- OpColor(&theColor);
-
- // Copy source 1 into the destination
- CopyBits((BitMap *)&(*theData)->source1->portPixMap,
- (BitMap *)&(*theData)->destination->portPixMap,
- &box, &box, srcCopy, nil);
-
- // Fill source 1 with black. We'll temporarily use source 1 to blend
- // source 2 with black.
- SetGWorld((*theData)->source1, nil);
- PaintRect(&box);
- SetGWorld(oldWorld, oldDev);
-
- // Blend source 2 with black (into source 1)
- CopyBits((BitMap *)&(*theData)->source2->portPixMap,
- (BitMap *)&(*theData)->source1->portPixMap,
- &box, &box, blend, nil);
-
- // Reset the OpColor to white and addPin source 1 (which contains source 2
- // blended with black) into the destination (which contains source 1).
- OpColor(&pin);
- CopyBits((BitMap *)&(*theData)->source1->portPixMap,
- (BitMap *)&(*theData)->destination->portPixMap,
- &box, &box, addPin, nil);
-
- } else {
- // We're in the second half of the transition (50% - 100%)
-
- // Calculate the mixing value and set OpColor accordingly
- theColor.red = theColor.green = theColor.blue = 131072 - spot;
- OpColor(&theColor);
-
- // Copy source 2 into the destination
- CopyBits((BitMap *)&(*theData)->source2->portPixMap,
- (BitMap *)&(*theData)->destination->portPixMap,
- &box, &box, srcCopy, nil);
-
- // Fill source 2 with black. We'll temporarily use source 2 to blend
- // source 1 with black.
- SetGWorld((*theData)->source2, nil);
- PaintRect(&box);
- SetGWorld(oldWorld, oldDev);
-
- // Blend source 2 with black (into source 1)
- CopyBits((BitMap *)&(*theData)->source1->portPixMap,
- (BitMap *)&(*theData)->source2->portPixMap,
- &box, &box, blend, nil);
-
- // Reset the OpColor to white and addPin source 2 (which contains source 1
- // blended with black) into the destination (which contains source 2).
- OpColor(&pin);
- CopyBits((BitMap *)&(*theData)->source2->portPixMap,
- (BitMap *)&(*theData)->destination->portPixMap,
- &box, &box, addPin, nil);
- }
- break;
- case esSetup:
- break;
- }
-
- // Leave destination set up nicely
- SetGWorld((*theData)->destination, nil);
- ForeColor(blackColor);
- BackColor(whiteColor);
-
- // Reset the GWorld/GDevice
- SetGWorld(oldWorld, oldDev);
-
- return(result);
- }
-